/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DataObject;

import java.io.Serializable;
import java.util.Vector;

/**
 *
 * @author Backkom
 */
public class ServerInfo implements Serializable {

    public String databasesName;
    String[] tablesName;
    String[] primaryKeys;
    Vector<String[]> ColumnsName;
    Vector<String[]> typesName;

    public ServerInfo(String databases, String[] tables, String[] primaryKeyName, Vector<String[]> columns, Vector<String[]> types) {
        databasesName = databases;
        tablesName = tables;
        primaryKeys = primaryKeyName;
        ColumnsName = columns;
        typesName = types;
    }

    public String[] getColumns(String tbname) {
        for (int i = 0; i < tablesName.length; i++) {
            if (tablesName[i].equals(tbname)) {
                return ColumnsName.get(i);
            }
        }
        return null;
    }

    public String getKey(String tbname) {
        for (int i = 0; i < tablesName.length; i++) {
            if (tablesName[i].equals(tbname)) {
                if(primaryKeys[i] == null)
                    return "";
                return primaryKeys[i];
            }
        }
        return null;
    }

    public String[] getTypes(String tbname) {
        for (int i = 0; i < tablesName.length; i++) {
            if (tablesName[i].equals(tbname)) {
                return typesName.get(i);
            }
        }
        return null;
    }

    public String[] getTables() {
        return tablesName;
    }
}
